﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DTOService;
using System.Data;



namespace DAOService
{
    public class DAOQuyDinh : IDAOQuyDinh
    {
        Provider p = new Provider();

        public QuyDinh SelectQuyDinh()
        {
            DataTable dt = p.ExecuteStoreProcedure("sp_QuyDinh");
            QuyDinh rs = new QuyDinh();
            rs.SoLuongThueToiDa = int.Parse(dt.Rows[0]["SoLuongThueToiDa"].ToString());
            rs.SoNgayThueToiDa = int.Parse(dt.Rows[0]["SoNgayThueToiDa"].ToString());
            rs.TienDatCoc = float.Parse(dt.Rows[0]["TienDatCoc"].ToString());
            rs.TienPhatTraTre = float.Parse(dt.Rows[0]["TienPhatTraTre"].ToString());
            return rs;
        }

        public int UpdateQuyDinh(QuyDinh parr)
        {
            DataTable dt = p.ExecuteStoreProcedure("sp_ThayDoiQuyDinh", new string[] { "songaythuetoida", "tienphattratre", "tiendatcoc", "soluongthuetoida" }, new object[] { parr.SoNgayThueToiDa, parr.TienPhatTraTre, parr.TienDatCoc, parr.SoLuongThueToiDa });
            return int.Parse(dt.Rows[0][0].ToString());
        }
    }
}
